package com.woniu.park.controller;


import com.woniu.park.dao.CouponMapper;
import com.woniu.park.entity.Coupon;
import com.woniu.park.entity.User;
import com.woniu.park.service.ICouponService;
import com.woniu.park.util.Result;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cxb
 * @since 2020-09-05
 */
@RestController
//@RequestMapping("/park/coupon")
@Slf4j
public class CouponController {

    @Autowired
    private ICouponService iCouponService;

    /*
        优惠劵获取
     */
    @GetMapping("dc")
    public Result  discountCoupons(){
        User user = (User) SecurityUtils.getSubject().getPrincipal();
        int userId = user.getUserId();
        List<Coupon> list = iCouponService.discountCoupons(userId);
        return Result.success("1","优惠价查询成功",list);
    }
 /*   @GetMapping("dc")
    public Result  discountCoupons(int userId){

        List<Coupon> list = iCouponService.discountCoupons(userId);
        return Result.success("1","优惠价查询成功",list);
    }*/
}

